package com.bjfu.mapper;

import org.apache.ibatis.annotations.*;
import com.bjfu.model.ErrorInfo;

import java.util.List;

@Mapper
public interface ErrorInfoMapper {
    // 插入错误信息的方法
    @Insert("INSERT INTO error_info (type_id, type, cause) VALUES (#{typeId}, #{type}, #{cause})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insertErrorInfo(ErrorInfo errorInfo);

    // 根据type_id和type获取审核理由
    @Select("SELECT * FROM error_info WHERE type_id = #{typeId} AND type = #{type}")
    List<ErrorInfo> getErrorInfoByTypeIdAndType(Long typeId, Integer type);

    // 更新错误原因
    @Update("UPDATE error_info SET cause = #{cause} WHERE id = #{errorId}")
    void updateErrorInfoCause(String cause,  Long errorId);
}
